<?php TPL::output('admin/global/header.tpl.htm'); ?>
<!--left-->
<?php TPL::output('admin/global/left.tpl.htm'); ?>
<!--left-->
<!-- main -->
<div id="main-content">
	<div class="clear"></div>
	<div class="content-box">
		<div class="content-box-header">
			<h3>专辑:<?php print_r( $this->list[0]["title"]); ?></h3>
			<ul class="content-box-tabs">
				<li><a href="#tab1" class="default-tab current">网站列表</a></li>
				<li><a class="" href="#tab2">添加网站</a></li>
			</ul>
			<div class="clear"></div>
		</div>
		<div class="content-box-content">
			<div class="tab-content default-tab" id="tab1">
				<?php if($this->list){ ?>
				<table class="list">
					<thead>
						<tr>
							<th style="width:40px;" align="center">ID</th>
							<th>站点标题</th>
                            <th>评论</th>
							<th>评分</th>
							<th>操作</th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<td colspan="6"><div class="pagination"> <?php echo $this->pagination; ?> </div>
								<div class="clear"></div></td>
						</tr>
					</tfoot>
					<tbody style="border-bottom: 1px solid #ddd;">
						<?php foreach ($this->list AS $key => $val) { ?>
						<tr style="vertical-align:middle;">
							<td align="center"><?php echo $val['id']; ?></td>
							<td><a href="special/<?php echo $val['id']; ?>" target="_blank"><?php echo $val['question_content']; ?></a></td>
							<td><?php echo $val['comment']; ?></td>
							<td><?php echo $val['score']; ?></td>
							<td><a href="admin/special/site_edit/qs_id-<?php echo $val['id']; ?>" title="编辑专辑"><img src="<?php echo G_STATIC_URL;?>/admin/images/icons/pencil.png"/></a> &nbsp; <a href="javascript:void(0);" onClick="ajax_request(G_BASE_URL + '/admin/special/delete_special_question_ajax/qs_id-<?php echo $val['id']; ?>');" name="remove" title="解除网站"><img src="<?php echo G_STATIC_URL;?>/admin/images/icons/cross.png" /></a></td>
						</tr>
						<?php } ?>
					</tbody>
				</table>
				<?php } ?>
			</div>
			<div class="tab-content" id="tab2" style="display: none;">
				<div id="notification_box" class="notification success png_bg" style="display:none;"> <a class="close" href="javascript:;"></a>
					<div name="notification_content"></div>
				</div>
				<h3>添加网站</h3>
					<p>
                    <form id="_save_form" action="admin/special/saveSite_ajax/" method="post">
						<label>网站标题：</label>
						<input class="text-input medium-input" autocomplete="off" name="q" value="" onSubmit="return false;" id="s_search" data-category_enable="<?php echo (get_setting('category_enable') == 'Y') ? 1 : 0; ?>" title="搜索站点..."/>
                        <input type="hidden" name="siteId" id="siteId" value=""/>
                        <input type="hidden" name="special_id" id="special_id" value="<?php echo intval($_GET['special_id']); ?>"/>
					</p>
					<p>
						<label>网站评论：</label>
                        <textarea id="comment" rows="3" cols="90" name="comment"></textarea>
					</p>
					<p>
						<label>网站评分：</label>
                         <!--    评星插件 BEGIN    -->
                         
                        <div id="star" style ="width:150px;float:left"></div>
                        <div id ="star_result" style ="float:left;width:300px;height:20px"></div>
                        
                         <!--    评星插件 END   -->
					</p>					
					<p>
						<input class="button" type="button" onClick="ajax_post($('#_save_form'), _form_process);" value="添加新网站" />
					</p>
				</form>
			</div>
		</div>
	</div>
	<!-- footer -->
	<?php TPL::output('admin/global/footer.tpl.htm'); ?>
	<!-- footer -->
</div>
<!-- main -->
</div>
<script type="text/javascript">
var url="?/admin/special/ajax_search/?"	;

$('#star').raty({
	hintList:  ['好烂呀', '不好用', 'soso啦', '不错哦', '给力，我喜欢'],
	path:"static/common/img",
	onClick: function(score) {
		set_score(score);
	  },
	  
	  
	//  start:"<?php echo $this->question_info['question_score'] ?>",
	//  showHalf:  true
	//target:'#star_result',
	//targetKeep:true

	
	
});
$("#s_search").bind('keyup',function(){	
  url="?/admin/special/ajax_search/?q="+$(this).val()			;						 
});
var emails2=[{sitename:'test1',py:'yanchao',sid:'1'}];							   
		$("#s_search").autocomplete('?/admin/special/ajax_search/?', {
			minChars: 0,
			mustMatch: true,
			width: 350,			
			matchContains: true,
			selectFirst: true,
			cacheLength: 1,
			autoFill: false,
			matchCase: true,
//需要把data转换成json数据格式
            parse: function(data) {
            return $.map(eval(data), function(row) {
                return {
                    data: row,
                    value: row.sitename,
                  //  result: row.sitename + " <" + row.sid + ">"
                    result: row.sitename 
                }
            });
        },			
			formatItem: function(row, i, max) {
				return i + "/" + max + ": " + row.sitename;
			},
			formatMatch: function(row, i, max) {
				return row.sitename + "-" + row.sid + "-" + row.sid;
			},
			formatResult: function(row) {
				return row.sitename;
			}
		}).result(function(event, data, formatted) {
			if ($(this).val() != "") {
				$("#siteId").val(data['sid']);
			}else{
				$("#siteId").val("");
			}	
		});	
</script>
</body></html>